package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.FamilyRelations;
import com.ruoyi.personnel.mapper.FamilyRelationsMapper;
import com.ruoyi.personnel.service.IFamilyRelationsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 家庭关系（与人员信息关联）Service业务层处理
 *
 * @author ruoyi
 * @date 2021-02-23
 */
@Service
public class FamilyRelationsServiceImpl extends ServiceImpl<FamilyRelationsMapper, FamilyRelations> implements IFamilyRelationsService {

    @Override
    public List<FamilyRelations> queryList(FamilyRelations familyRelations) {
        LambdaQueryWrapper<FamilyRelations> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(familyRelations.getRelationship())){
            lqw.eq(FamilyRelations::getRelationship ,familyRelations.getRelationship());
        }
        if (StringUtils.isNotBlank(familyRelations.getName())){
            lqw.like(FamilyRelations::getName ,familyRelations.getName());
        }
        if (StringUtils.isNotBlank(familyRelations.getAddress())){
            lqw.eq(FamilyRelations::getAddress ,familyRelations.getAddress());
        }
        if (StringUtils.isNotBlank(familyRelations.getPhone())){
            lqw.eq(FamilyRelations::getPhone ,familyRelations.getPhone());
        }
        if (StringUtils.isNotBlank(familyRelations.getPersonnelId())){
            lqw.eq(FamilyRelations::getPersonnelId ,familyRelations.getPersonnelId());
        }
        return this.list(lqw);
    }
}
